/**
 * Marco Mounzer
 * m.mounzer@gmail.com
 * @copyright 2013
 */

function ChangeCenterPage(modulo, oggetto, id) {
    window.document.location = (modulo ? ('/' + modulo) : '') + '/' + oggetto + '.php' + (id != null ? '?id=' + id : '');
    document.body.style.cursor = 'wait';
}

var popupWindow=null;
function popup(mypage,myname,w,h,pos,infocus){
    if (pos == 'random')
    {
        LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
        TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    else
    {
        LeftPosition=(screen.width)?(screen.width-w)/2:100;
        TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    popupWindow=window.open('',myname,settings);
    if(infocus=='front'){
        popupWindow.focus();
        popupWindow.location=mypage;
    }
    if(infocus=='back'){
        popupWindow.blur();
        popupWindow.location=mypage;
        popupWindow.blur();
    }

}

function getParameterByName(name)
{
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.search);
    if(results == null)
        return false;
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}